﻿
@{
    ViewBag.Title = "GetQueAdmin";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
    var data = ViewBag.Data as List<LPY.LeHealth.DTO.questions>;
}

@section Header{
    <link href="~/Asset/font-awesome-4.6.3/css/font-awesome.min.css" rel="stylesheet" />
    <script src="~/Asset/esimakin-twbs-pagination/jquery.twbsPagination.min.js"></script>
}
<script>
    //$(document).ready(function () {
    //    $.ajax({
    //        url: '/Admin/GetQueShow',
    //        type: 'post',
    //        success: function (d) {
    //            $("#mytbody").empty();
    //            $(d).each(function (i, obj) {
    //                var d1 = '<tr><td>' + obj.content + '</td><td>' + obj.Qphone + '</td><td>' + obj.Qstate + '</td><td>' + obj.Qdate + '</td> <td style="width:10%;"><div class="btn-group"><a href="#" class="btn btn-default btn-sm">管理</a> <a href="#" type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><span class="caret"></span> </a><ul class="dropdown-menu"><li><a id="edit" href="#" data-id="' + obj.Id + '">回复</a></li><li><a href="#" onclick="return confirm(\'确定要删除吗？\')">删除</a></li> </ul></div></td></tr>';
    //                $("#mytbody").append(d1);
    //            })
    //        }
    //    })
    //})


</script>



<div class="content">
    <div class="row">
        <div class="col-md-2">
            <div class="list-group">
                @*<a href="@Url.Action("Hospital", "Admin")" class="list-group-item">医院管理</a>*@
                <a href="@Url.Action("GetHospitalAdmin", "Admin")" class="list-group-item ">医院管理员管理</a>
                @*<a href="@Url.Action("GetQueAdmin", "Admin")" class="list-group-item">问答管理员管理</a>*@ 

            </div>
        </div>
        <div class="modal fade" id="modal_add_user" tabindex="-1" role="dialog" aria-labelledby="label_course">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    
                    <div class="modal-footer">
                        <div id="doing" style="float:left;display:none;">
                            <i class="fa fa-circle-o-notch fa-spin"></i><span> 处理中...</span>
                        </div>
                        <div id="success" style="float: left; display: none; ">
                            <i class="fa fa-check-square"></i><span> 保存成功！</span>
                        </div>
                        <div id="error" style="float: left; display: none; ">
                            <i class="fa fa-warning"></i><span> 保存失败！</span>
                        </div>

                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button id="btn_add_hospital" type="button" class="btn btn-primary">提交</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-10">
            <div class="page-header clearfix" style="padding:10px;">
                <h4 class="pull-left">医院管理员列表</h4>
                <!--操作按钮-->
                
            </div>

            <!--内容区域-->
            @*<form id="user-search-form" class="form-inline well well-sm" action="/Exam/QueryExam" method="post" novalidate="">
                    <div class="form-group">
                        <input type="text" id="keyword" name="ExamName" class="form-control" value="" placeholder="添加相关词">
                    </div>
                    <button class="btn btn-primary" type="submit">搜索</button>
                </form>*@

            

            <table id="user-table" class="table table-striped table-hover" data-search-form="#user-search-form">
                <thead>
                    <tr>
                        <td>问答内容</td>
                        <td>联系方式</td>
                        <td>问答状态</td>
                        <td>问答时间</td>
                        <td>操作</td>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in data)
                    {
                        <tr>
                            <td style="width:20%;">@item.content</td>
                            <td>@item.Qphone</td>
                            <td style="width:10%;">@item.Qstate</td>
                            <td style="width:10%;">@item.Qdate</td>
                            <td style="width:10%;">
                                <div class="btn-group">

                                    <a href="#" class="btn btn-default btn-sm">管理</a>
                                    <a href="#" type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                                        <span class="caret"></span>
                                    </a>

                                    <ul class="dropdown-menu">
                                        <li><a class="edit" href="#" data-id="@item.Id">回复</a></li>
                                        <li><a class="delete" href="#" data-id="@item.Id">删除</a></li>
                                    </ul>
                                </div>
                            </td>
                        </tr>
                    }

                </tbody>
            </table>

            <!--分页-->
            <nav class=" text-center">
                <ul id="pagination" class="pagination-sm"></ul>
            </nav>
        </div>
    </div>
</div>

<div class="modal fade" id="modal_edit" tabindex="-1" role="dialog" aria-labelledby="label_course">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="label_course"><strong>编辑体检项目</strong></h4>
            </div>
            <div class="modal-body">
                <input type="hidden" id="curren_id" />
                <div class="row form-group">
                    <div class="col-md-3 control-label">
                        <label for="NameEdit" class="pull-right">提问问题</label>
                    </div>
                    <div class="col-md-7 controls">
                        <input id="NameEdit" class="form-control" type="text">
                    </div>
                </div>
                @*<div class="row form-group">
                    <div class="col-md-3 control-label">
                        <label for="PriceEdit" class="pull-right">价格</label>
                    </div>
                    <div class="col-md-7 controls">
                        <input id="PriceEdit" type="number" class="form-control">
                    </div>
                </div>*@

                <div class="row form-group">
                    <div class="col-md-3 control-label">
                        <label for="PurposeEdit" class="pull-right">回答问题</label>
                    </div>
                    <div class="col-md-7 controls">
                        <textarea id="PurposeEdit" class="form-control" style="height:180px;"></textarea>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <div id="doing" style="float:left;display:none;">
                    <i class="fa fa-circle-o-notch fa-spin"></i><span> 处理中...</span>
                </div>
                <div id="success" style="float: left; display: none; ">
                    <i class="fa fa-check-square"></i><span> 保存成功！</span>
                </div>
                <div id="error" style="float: left; display: none; ">
                    <i class="fa fa-warning"></i><span> 保存失败！</span>
                </div>

                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button id="btn_model_edit" type="button" class="btn btn-primary">提交</button>
            </div>
        </div>
    </div>
</div>



@section Footer{
    <script type="text/javascript">
    $(function () {


        $('#pagination').twbsPagination({
            totalPages: '@ViewBag.TotalPage',
            visiblePages: 5,
            first: "首页",
            prev: "上一页",
            next: "下一页",
            last: "尾页",
            href: '/Admin/GetQueShow?pageIndex={{pageNumber}}',
            hrefVariable: '{{pageNumber}}'
        });
    });

    $(".edit").click(function () {
        var id = $(this).attr("data-id");
        $.ajax({
            url: '@Url.Action("GetIdShow", "Admin")',
                data: { id: id },
                type: 'post',
                success: function (data)
                {

                    if (data.Code = 1) {
                        $("#NameEdit").val(data.Data[0].content);
                        //$("#PriceEdit").val(data.Data .Qphone);
                        //$("#PurposeEdit").val(data.Data.Qstate);
                        $("#curren_id").val(data.Data[0].Id);
                        $("#modal_edit").modal('show');
                    }
                }
            });
        });


        //编辑
        $("#btn_model_edit").click(function () {
                
                var Qid = $("#curren_id").val();
                var huida = $("#PurposeEdit").val();
                var date = '2016-05-06';
                var name = "Admin";

                $.ajax({
                    url: '@Url.Action("AddReplyd", "Admin")',
                    type: "post",
                    data: { Qid: Qid, Rcontent: huida, Rdate: date, Pname: name },
                    success: function (data) {
                        if (data.Code = 1) {
                            alert('回复成功');
                            $("#doing").hide();
                            $("#success").show();
                            setTimeout(function () {
                                $("#modal_add_course").modal('hide');
                                window.location.href = '@Url.Action("GetQueAdmin", "Admin")';
                            }, 1000);
                            
                        }
                        else {
                            $("#doing").hide();
                            $("#error").show();
                        }
                        }
                    //},
                    //beforeSend: function (xhr) {
                    //    $("#btn_add_course").attr({ "disabled": "disabled" });
                    //    $("#doing").show();
                    //},
                    //complete: function (xhr, status) {
                    //    $("#doing").hide();
                    //}
                });
            });
    </script>
}






